<!DOCTYPE html>
<head>
    <#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
    <#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
    <#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
    <#assign DutyDept = JspTaglibs["http://www.casic304.cn/DutyDept"]/>
    <meta charset="utf-8">
    <title>质量问题基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <form class="formPreview layui-form" requrl="${ctx}/qbdms/wQbdFalProblemreset/get" lay-filter="wQbdFalProblemresetDataForm" id="wQbdFalProblemresetDataForm">
            <div class="layui-hide">
                <input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input " maxlength="50">
                <input name="filldeptid" value="${filldeptid}" style="display: none"/>
                <input name="filldept" value="${filldept}" style="display: none"/>
                <input name="fillmanaccount" value="${fillmanaccount}" style="display: none"/>
                <input name="fillman" value="${fillman}" style="display: none"/>
                <input name="filldate" value="${filldate}" style="display: none"/>
                <input name="fSuperviseid" value="${fSuperviseid}" style="display: none"/>
            </div>
            <div class="qbdms-formTitle">质量问题信息 <i class="qbdms-returnOn closeWindow" id="back">返回</i></div>
            <div class="qbdms-formBody">
                <@fillDept.dept id="tbxx"/>
                <div class="layui-row">
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="质量问题名称">质量问题名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required" name="fProblemname" lay-reqtext="质量问题名称是必填项" maxlength="50">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select data_src=1 required=true name="secret"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="问题发生时间">问题发生时间<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" placeholder="请选择" autocomplete="off" readonly class="layui-input dateTimeFiled input-right time-init" id="fDetecttime" name="fDetecttime" format="yyyy-MM-dd" datetype="date" lay-verify="required" lay-reqtext="问题发生时间是必填项">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="型号代号">型号代号<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select id="fModelsymbol" name="fModelsymbol" class="layui-input filter-value" lay-search="" lay-verify="required" lay-reqtext="型号代号是必填项" lay-filter="xh" maxlength="50"></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="型号名称">型号名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" placeholder="根据型号代号自动填写" autocomplete="off" class="layui-input textInput isReadonlyInput" name="fModelname" maxlength="100" lay-verify="required" lay-reqtext="型号名称是必填项" disabled>
                        </div>
                    </div>

                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="型号类别">型号类别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fModeltype" nodeKey="xhlx" verify="required" reqtext="型号类别是必填项" />
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="工作阶段">工作阶段<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fWorkphase1" nodeKey="gzjd" verify="required" reqtext="工作阶段是必填项" search=true/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="故障产品名称">故障产品名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" placeholder="请输入" name="fProductname" autocomplete="off" class="layui-input " maxlength="50" title="能分解到组合级的分解不到整机的填分系统" lay-verify="required" lay-reqtext="故障产品名称是必填项">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="型号研制阶段">型号研制阶段<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fModeldevelopphase" nodeKey="xhyzjd" verify="required" reqtext="型号研制阶段是必填项" search=true />
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="故障件阶段">故障件阶段<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fBreakphase" nodeKey="gzjjd" verify="required" reqtext="故障件阶段是必填项" search=true/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="是否首飞"><span style="color: red;">*</span>是否首飞</label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fIffirstfly" nodeKey="sf" search=true verify="required" reqtext="是否首飞是必填项"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="是否靶场质量问题"><span style="color: red;">*</span>是否靶场质量问题</label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fIfshooting" nodeKey="sf" search=true verify="required" reqtext="是否靶场质量问题是必填项"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="问题级别">问题级别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="fProblemlever" nodeKey="wtjb" nowItemValue="场所级" verify="required" reqtext="问题级别是必填项" search=true/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="问题发生地点"><span style="color: red;">*</span>问题发生地点</label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="fDetectplace" maxlength="100"  lay-verify="required" lay-reqtext="问题发生地点是必填项">
                        </div>
                    </div>

                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="责任单位（研究室）"><span style="color: red;">*</span>责任单位（研究室）</label>
                        <div class="layui-input-block qbdms-input">
                            <select id="fDutydept" name="fDutydeptRoom" autocomplete="off"
                                    class="layui-input" lay-filter="fDutydeptRoom"
                                    fieldname="fDutydeptRoom" lay-verify="required"
                                    lay-reqtext="责任单位（研究室）是必填项">
                            </select>
                        </div>
                        <input type="hidden" name="fDutydeptRoomName" id="fDutydeptRoomName">
                    </div>

                    <div class="qbdms-textarea">
                        <label class="layui-form-label qbdms-label">问题/故障现象描述<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <textarea rows="2" class="layui-textarea" placeholder="请输入" name="fFailuredescription" maxlength="650" lay-verify="required" lay-reqtext="问题/故障现象描述是必填项"></textarea>
                        </div>
                    </div>
                    <#if isInclude=='true'>
                    <#include "/wQbdFalProblemreset/two.html">
                </#if>

                <#if flowStatus != "0" && flowStatus !="''" && flowStatus !="99">

                    <div class="qbdms-textarea flowing" style="display: none">
                        <label class="layui-form-label qbdms-label">本单位型号主管审批</label>
                        <div class="layui-input-block qbdms-input" style="border:1px solid #E4E7ED;padding:10px 6px">
                            <#list taskOpinionNewList as taskOpinionNewList>
                                <#if taskOpinionNewList.taskName == "本单位型号主管审批">
                                    <p>${taskOpinionNewList.opinion}</p><br/>
                                    <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                    日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                                </#if>
                            </#list>
                        </div>
                    </div>

                    <div class="qbdms-textarea flowing" style="display: none">
                        <label class="layui-form-label qbdms-label">型号主管助理员审批</label>
                        <div class="layui-input-block qbdms-input" style="border:1px solid #E4E7ED;padding:10px 6px">
                            <#list taskOpinionNewList as taskOpinionNewList>
                            <#if taskOpinionNewList.taskName == "型号主管助理员审批">
                            <p>${taskOpinionNewList.opinion}</p><br/>
                            <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                        </#if>
                    </#list>
                    </div>
                    </div>

                    <div class="qbdms-textarea flowing" style="display: none">
                        <label class="layui-form-label qbdms-label">型号主管部门领导审批</label>
                        <div class="layui-input-block qbdms-input" style="border:1px solid #E4E7ED;padding:10px 6px">
                            <#list taskOpinionNewList as taskOpinionNewList>
                            <#if taskOpinionNewList.taskName == "型号主管部门领导审批">
                            <p>${taskOpinionNewList.opinion}</p><br/>
                            <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                        </#if>
                    </#list>
                    </div>
                    </div>

                    <div class="qbdms-textarea flowing" style="display: none">
                        <label class="layui-form-label qbdms-label">质量综合助理员确认</label>
                        <div class="layui-input-block qbdms-input" style="border:1px solid #E4E7ED;padding:10px 6px">
                            <#list taskOpinionNewList as taskOpinionNewList>
                            <#if taskOpinionNewList.taskName == "质量综合助理员确认">
                            <p>${taskOpinionNewList.opinion}</p><br/>
                            <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                        </#if>
                    </#list>
                    </div>
                    </div>

                </#if>
                </div>
            </div>

            <input type="hidden" name="flowStatus">
            <div class="layui-form-item btnformItem">
                <p>
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdFalProblemreset" class="layui-btn btn-n privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdFalProblemreset/save" id="urlFormSave">保存</a>
                        <a lay-filter="wProblemresetMsg" id="run" class="layui-btn btn-n qbdms-oneBtn">启动</a>
                        <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消</button>
                    </span>
                </p>
            </div>
        </form>
    </div>
</div>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/json/comboselect.js" type="text/javascript"></script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    var runFlag=false ;
    var vaildFlag ;
    var comboselect;
    var flowStatus="${flowStatus}";
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'layer', 'propsHandle', 'upload', 'common', 'laydate', 'jquery', 'publicMethods', 'qbdmsForm','form'], function () {

        // -----常量声明----------
        var $ = layui.jquery,
            laydate = layui.laydate,
            setter = layui.setter,  // 配置信息
            layer = layui.layer,
            common = layui.common,
            propsHandle = layui.propsHandle,
            upload = layui.upload,
            publicMethods = layui.publicMethods,
            formId = '${formDefId}' || '',
            defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                formAreaInfo: '.formPreview',
                formAreaInfo: 'html',
                temDate: '.temDate',
                uploadFileBtn: '.uploadFileBtn',
                uploadImgBtn: '.uploadImgBtn',
                richTextArea: '.richTextArea',
                selectInput: '.selectInput',
                radioOptionCont: '.radioOptionCont',
                dataLexiTree: '.dataLexiTree',
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle(),  // 实例化模板功能部分
            form = layui.qbdmsForm;
            forms = layui.form;
        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        $(".subContTem").hide();
        $(".qbdms-SubTableTitle").hide();
        $(".qbdms-tableDiv").hide();

        var researchRoomList = eval('${researchRoomList}'); //问题责任单位（研究室）
        var researchRoom = function(optionObj, item){
            optionObj.text = item.orgName;
            optionObj.value = item.code;
        };
        common.initDicData("fDutydeptRoom", researchRoomList, "", researchRoom);
        var dateTimeFiledLen = $(".dateTimeFiled");

        if("${isInclude}"=="true"){
            for (var i = 0; i < dateTimeFiledLen.length; i++) {
                laydate.render({
                    elem: dateTimeFiledLen[i] //指定元素
                    , type: 'date'
                    , trigger: 'click'
                    , done: computeResetDay
                });
            }
            function computeResetDay(data){
                // 自动计算：归零时间—问题发生时间
                // 若归零方式选择了“技术归零”，归零周期按技术归零时间算；
                // 若归零方式选择了“管理归零”，归零周期按管理归零时间算；
                // 若归零方式选择了“双归零”，归零周期按技术归零时间算。
                var fSkillresettime = $("[name='fSkillresettime']").val();
                var fManageresettime = $("[name='fManageresettime']").val();
                var fDetecttime = $("[name='fDetecttime']").val();
                var fResettype = $("[name='fResettype']").val();
                if(data){
                    data.fSkillresettime && (fSkillresettime=data.fSkillresettime);
                    data.fManageresettime && (fManageresettime=data.fManageresettime);
                    data.fDetecttime && (fDetecttime=data.fDetecttime);
                    data.fResettype && (fResettype=data.fResettype);
                }
                var fResetday = 0;
                if (fDetecttime == "" || fResettype == "") { return; }

                if (fResettype == "技术归零") {
                    fResetday = fSkillresettime == "" ? 0 : GetNumberOfDays(fSkillresettime, fDetecttime);
                } else if (fResettype == "管理归零") {
                    fResetday = fManageresettime == "" ? 0 : GetNumberOfDays(fManageresettime, fDetecttime);
                } else if (fResettype == "双归零") {
                    fResetday = fSkillresettime == "" ? 0 : GetNumberOfDays(fSkillresettime, fDetecttime);
                } else {
                    fResetday = 0;
                }
                $("[name='fResetday']").val(fResetday);
            }

            function GetNumberOfDays(endDate, beginDate) {//获得天数
                //beginDate：开始日期，endDate 结束日期
                var end = Date.parse(new Date(endDate));
                var begin = Date.parse(new Date(beginDate));
                var day = parseInt((end - begin) / (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数
                return day;
            }
        }else{
            for (var i = 0; i < dateTimeFiledLen.length; i++) {
                laydate.render({
                    elem: dateTimeFiledLen[i] //指定元素
                    , type: 'date'
                    , trigger: 'click'
                    // , done: computeResetDay
                });
            }
        }



        //- 添加表单验证规则 开始 ---------------------------------------------------------------------
        form.verify({
            length100:[/^.{0,100}$/,'输入字符数不能超过100'],
            length2000:[/^.{0,2000}$/,'输入字符数不能超过2000'],
            fileRequired: function (value,item) {
                value = $(item).siblings(".uploadInput").val()
                if(!new RegExp(/[\S]+/).test(value)){
                    return common.verifyTitleAdd(item) +"没有上传对应附件"
                }
            },
            money: function (value,item) {
                if (value && !new RegExp(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/).test(value)) {
                    return common.verifyTitleAdd(item) +'请输入数字且小数最多两位';
                }
            },
            integer: function (value,item) {
                if (value && !new RegExp(/^[+]{0,1}(\d+)$/).test(value)) {
                    return common.verifyTitleAdd(item) + '请输入正整数';
                }
            }
        });
        //- 添加表单验证规则 结束 ---------------------------------------------------------------------

        form.on('select(xh)', function (data) {
            $("input[name='fModelname']").val(data.elem[data.elem.selectedIndex].getAttribute("xhmc"));
        });

        vaildFlag = false;
        $("#urlFormSave").click(function () {
            var fDetecttime = $("[name='fDetecttime']").val();
            var fSkillresettime = $("[name='fSkillresettime']").val();
            var fManageresettime = $("[name='fManageresettime']").val();
            var fmtDate = new Date(fDetecttime.replace(/\-/g, "\/"));
            if (fSkillresettime) {
                if (fmtDate > new Date(fSkillresettime.replace(/\-/g, "\/"))) {
                    layer.msg('技术归零时间，不能早于问题发生时间。', {icon: 5});
                    vaildFlag = false;
                    return false;
                }
            }
            if (fManageresettime) {
                if (fmtDate > new Date(fManageresettime.replace(/\-/g, "\/"))) {
                    layer.msg('管理归零时间，不能早于问题发生时间。', {icon: 5});
                    vaildFlag = false;
                    return false;
                }
            }

            var selectMaxVal = 0;
            var formSecretVal = $("[name='secret']").val();
            $(".fileSecLevel select").each(function () {
                selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
            });

            if (selectMaxVal > formSecretVal) {
                layer.msg('附件密级不能高于表单密级。', {icon: 5});
                vaildFlag = false;
                return false;
            }
            vaildFlag=form.VerifyForm("wQbdFalProblemresetDataForm");
        });


        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            var mdb = "${db}";
            if(null != mdb && 'db' === mdb && undefined != mdb){
                window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalSupervise/view/list';
                return;
            }
            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
        });

        if(flowStatus == null || flowStatus == 0|| flowStatus==99){
            $("#hideAndShow").show();
        }else{
            $("#back").hide();
        }
        if(flowStatus==99){
            $("#run").hide();
        }
        form.on('select(fDutydeptRoom)', function (data) {
         $("#fDutydeptRoomName").val(data.elem[data.elem.selectedIndex].text);
        });
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name: 'wQbdFalProblemresetDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {
                if("${isInclude}"=="true") {
                    var fDetecttime = $("[name='fDetecttime']").val();
                    var fSkillresettime = $("[name='fSkillresettime']").val();
                    var fManageresettime = $("[name='fManageresettime']").val();
                    var fResettype = $("[name='fResettype']").val();
                    var fmtDate = new Date(fDetecttime.replace(/\-/g, "\/"));
                    if (fSkillresettime) {
                        if (fmtDate > new Date(fSkillresettime.replace(/\-/g, "\/"))) {
                            layer.msg('技术归零时间，不能早于问题发生时间。', {icon: 5});
                            return false;
                        }
                    }
                    if (fManageresettime) {
                        if (fmtDate > new Date(fManageresettime.replace(/\-/g, "\/"))) {
                            layer.msg('管理归零时间，不能早于问题发生时间。', {icon: 5});
                            return false;
                        }
                    }

                    //- 归零时间整理 开始 ------------------------------------------------------
                    if (fResettype == "技术归零" || fResettype == "双归零") {
                        data.field["fResettime"] = fSkillresettime;
                    } else if (fResettype == "管理归零") {
                        data.field["fResettime"] = fManageresettime;
                    } else {
                        data.field["fResettime"] = "";
                    }
                    //- 归零时间整理 结束 ------------------------------------------------------

                    //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                    var selectMaxVal = 0;
                    var formSecretVal = $("[name='secret']").val();
                    $(".fileSecLevel select").each(function () {
                        selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                    });

                    if (selectMaxVal > formSecretVal) {
                        layer.msg('附件密级不能高于表单密级。', {icon: 5});
                        return false;
                    }
                    //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                    $(".uploadFileList").each(function (i, v) {
                        common.constructFileStr(v)
                    });
                    var files = [];
                    //整理上传附件的隐藏域，将提交的字符串转为json对象
                    $(".uploadInput").each(function () {
                        var uploadName = $(this).attr("name");
                        if (!$(this).val()) {
                            return;
                        }
                        data.field[uploadName] = eval($(this).val());
                        files = files.concat(eval($(this).val()));
                    });
                    // 控制文件密级
                    return common.setFileLevel(files);
                }
            },
            getCallback: function (data) {
                $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【" + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate + "】</span>");
                if("${isInclude}"=="true") {
                    $('.uploadFileList').each(function () {
                        var fileUploadName = $(this).attr("fileUploadName");
                        var jsonFile = data.data[fileUploadName];
                        var files = eval(jsonFile);

                        if (files) {
                            for (var i = 0; i < files.length; i++) {
                                var fileLevel = files[i].fileLevel;
                                var fileLevelText = files[i].fileLevelText;
                                var fileSec = '<div class="fileSecLevel layui-input-inline">'
                                    + '<@secSelect.sec_select data_src=1 hasBlank=false/>'
                                    + "</div>";
                                var newStr = '<span class="file-id" style="margin-right: 20px;" fileId='
                                    + files[i].fileId + ' fileLevelText="' + fileLevelText + '">'
                                    + fileSec
                                    + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>'
                                    + files[i].fileName
                                    + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                                $(this).append(newStr);
                                $(this).find("select:last").val(fileLevel);
                            }
                        }
                    });
                    comboselect.setDefaultValueByArr(data.data["fCausationclass1"], data.data["fCausationclass2"]);
                    form.render("select");
                    //-修改页面 级联下拉 原因分类 结束 ------------------------------------------

                    //-修改页面 外协外购 开始 ---------------------------------------------------
                    var fCausationclass1 = data.data["fCausationclass1"];
                    if (fCausationclass1 == "外协" || fCausationclass1 == "外购") {
                        $(".waixieTr").show();
                        common.setComponentRequired(["fOutdeptname", "fIfmating", "fIndusty", "fOutnature"], true);
                    }
                    //-修改页面 外协外购 结束 ---------------------------------------------------

                    //-修改页面 软件 开始 ------------------------------------------------------------
                    var fCausationclass1 = data.data["fCausationclass1"];
                    var fCausationclass2 = data.data["fCausationclass2"];
                    if (fCausationclass1 == "软件" || fCausationclass2 == "软件") {
                        $(".ruanjianTr").show();
                        common.setComponentRequired(["fSoftrank"], true);
                    }
                    //-修改页面 软件 结束 ------------------------------------------------------------
                    //是否归零
                    overRtnZero(data.data);
                    resetTypeChange(data.data);
                    scfl1(data.data.fProduceclass);
                }

            },
            updateCallback: function (data) {
                if((flowStatus==0||flowStatus==""||null==flowStatus)&&runFlag==true){
                    run(data.data.id);
                }
                if (publicMethods._filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    var mdb = "${db}";
                    if((flowStatus=="0" || flowStatus==null||flowStatus==""||flowStatus=="99")&&runFlag==false){
                        if(null != mdb && 'db' === mdb && undefined != mdb){
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                                layer.close(index);
                                window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalSupervise/view/list';
                            });
                        } else{
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                                layer.close(index);
                                window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
                            });
                        }
                    }
                    runFlag=false;
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }

        });
        if("${isInclude}"=="true") {
            //- 原因分类初始化 绑事件 开始 -------------------------------------------------------------
            var yyflsList = eval('${yyflsList}'); //原因分类
            var typeId = "${typeId}";
            comboselect = ComboSelectFactory(yyflsList, 'fCausationclass1', 'fCausationclass2','fCausationclass3');
            comboselect.setProperties({
                idKey: 'dicId',
                valueKey: 'itemValue',
                textKey: 'itemValue',
                parentIdKey: 'parentId',
                topParentValue: typeId
            });
            form.on('select(fProduceclass)', function (data) {
                    scfl(data.value);
            });
            function scfl(value){
                $("#fCausationclass1").attr("disabled",false);
                $("#fCausationclass3").attr("disabled",false);
                $('#fCausationclass1').attr("lay-search");
                $('#fCausationclass3').attr("lay-search");
                if (value == "外协" ||value == "外购") {
                    comboselect = ComboSelectFactory(yyflsList, 'fCausationclass1', 'fCausationclass2','fCausationclass3');
                    comboselect.setProperties({
                        idKey: 'dicId',
                        valueKey: 'itemValue',
                        textKey: 'itemValue',
                        parentIdKey: 'parentId',
                        topParentValue: typeId
                    });
                    $('#fCausationclass1').val(value);
                    $("#fCausationclass1").attr("disabled",true);
                    $('#fCausationclass1').removeAttr("lay-search");
                    $('#fCausationclass3').removeAttr("lay-search");
                }
                else if (value == "自产") {
                    var zcList = eval('${yyflsList}'); //原因分类
                    var isWaiXie=false;
                    var isWaiGou=false;

                    for(var i=0;i<zcList.length;i++){
                        if(zcList[i].itemName==="外协"&&!isWaiXie&&zcList[i].parentId=="4990bedf226c46eb95737e3dbb42ea15"){
                            zcList.splice(i,1);
                            isWaiXie=true;
                        }
                        if(zcList[i].itemValue==="外购"&&!isWaiGou&&zcList[i].parentId=="4990bedf226c46eb95737e3dbb42ea15"){
                            zcList.splice(i,1);
                            isWaiGou=true;
                        }
                        if(isWaiXie&&isWaiGou){
                            break;
                        }
                    }
                    $("#fCausationclass1").empty();
                    var  comboselect1 = ComboSelectFactory(zcList, 'fCausationclass1', 'fCausationclass2','fCausationclass3');
                    comboselect1.setProperties({
                        idKey: 'dicId',
                        valueKey: 'itemValue',
                        textKey: 'itemValue',
                        parentIdKey: 'parentId',
                        topParentValue: typeId
                    });
                    $("#fCausationclass3").attr("disabled",true);
                }else{
                    comboselect = ComboSelectFactory(yyflsList, 'fCausationclass1', 'fCausationclass2','fCausationclass3');
                    comboselect.setProperties({
                        idKey: 'dicId',
                        valueKey: 'itemValue',
                        textKey: 'itemValue',
                        parentIdKey: 'parentId',
                        topParentValue: typeId
                    });
                }
                yyfl1();
                comboselect.eventHandle(document.getElementById("fCausationclass1"), 0)();
                form.render("select");
                form.render();
            }
            function scfl1(value){
                $("#fCausationclass1").attr("disabled",false);
                $("#fCausationclass3").attr("disabled",false);
                $('#fCausationclass1').attr("lay-search");
                $('#fCausationclass3').attr("lay-search");
                if (value == "外协" ||value == "外购") {
                    $('#fCausationclass1').val(value);
                    $("#fCausationclass1").attr("disabled",true);
                    $('#fCausationclass1').removeAttr("lay-search");
                    $('#fCausationclass3').removeAttr("lay-search");
                }
                else if (value == "自产") {
                    var zcList = eval('${yyflsList}'); //原因分类
                    var isWaiXie=false;
                    var isWaiGou=false;

                    for(var i=0;i<zcList.length;i++){
                        if(zcList[i].itemName==="外协"&&!isWaiXie&&zcList[i].parentId=="4990bedf226c46eb95737e3dbb42ea15"){
                            zcList.splice(i,1);
                            isWaiXie=true;
                        }
                        if(zcList[i].itemValue==="外购"&&!isWaiGou&&zcList[i].parentId=="4990bedf226c46eb95737e3dbb42ea15"){
                            zcList.splice(i,1);
                            isWaiGou=true;
                        }
                        if(isWaiXie&&isWaiGou){
                            break;
                        }
                    }
                    $("#fCausationclass1").empty();
                    var  comboselect1 = ComboSelectFactory(zcList, 'fCausationclass1', 'fCausationclass2','fCausationclass3');
                    comboselect1.setProperties({
                        idKey: 'dicId',
                        valueKey: 'itemValue',
                        textKey: 'itemValue',
                        parentIdKey: 'parentId',
                        topParentValue: typeId
                    });
                    $("#fCausationclass3").attr("disabled",true);
                    $('#fCausationclass3').removeAttr("lay-search");
                }
                yyfl1();
                comboselect.eventHandle(document.getElementById("fCausationclass1"), 0)();
                form.render("select");
                form.render();
            }
            form.on('select(yyfl1)', function () {
                yyfl1();
            });
            function yyfl1(){
                comboselect.eventHandle(document.getElementById("fCausationclass1"), 0)();
                form.render("select");
                var componentNameArr = ["fOutdeptname", "fIfmating", "fIndusty", "fOutnature"];
                if ($("#fCausationclass1").val() == "外协" || $("#fCausationclass1").val() == "外购") {
                    $(".waixieTr").show();
                    common.setComponentRequired(componentNameArr, true);
                } else {
                    $(".waixieTr").hide();
                    common.setComponentRequired(componentNameArr, false);
                    common.clearComponentVal(componentNameArr);
                }

                if ($("#fCausationclass1").val() == "软件" || $("#fCausationclass2").val() == "软件") {
                    $(".ruanjianTr").show();
                    common.setComponentRequired(["fSoftrank"], true);
                } else {
                    $(".ruanjianTr").hide();
                    common.setComponentRequired(["fSoftrank"], false);
                    common.clearComponentVal(["fSoftrank"]);
                }

                form.render();
            }
            form.on('select(yyfl2)', function () {
                comboselect.eventHandle(document.getElementById("fCausationclass2"),1)();//三院的，第三极原因分类
                form.render("select");

                if ($("#fCausationclass1").val() == "软件" || $("#fCausationclass2").val() == "软件") {
                    $(".ruanjianTr").show();
                    common.setComponentRequired(["fSoftrank"], true);
                } else {
                    $(".ruanjianTr").hide();
                    common.setComponentRequired(["fSoftrank"], false);
                    common.clearComponentVal(["fSoftrank"]);
                }
            });
            //- 归零 绑事件 开始 -------------------------------------------------------------
            //是否完成归零
            form.on('select(fIfreset)', overRtnZero);

            function overRtnZero(data) {
                var fIfreset = $("[name='fIfreset']").val();
                data.fIfreset && (fIfreset = data.fIfreset);
                if (fIfreset == "是") {
                    common.setComponentRequired(["fResettype","fSubsystemname","fSubsystemnameFill","fCausationclass2","fProblemrank","qualityLeader","fCausation"], true);
                    if (data) {
                        resetTypeChange(data);
                    }
                } else {
                    common.setComponentRequired(
                        ["fResettype", "fSkillresettime", "fManageresettime"], false);
                    common.setComponentRequired(["fSkillcerfileList"], false, "fileRequired");
                    common.setComponentRequired(["fManagecerfileList"], false, "fileRequired");
                    common.setComponentRequired(["fSubsystemname","fSubsystemnameFill","fCausationclass2","fProblemrank","qualityLeader","fCausation"], false);
                }
            }

            //归零方式
            form.on('select(fResettype)', resetTypeChange);

            function resetTypeChange(data) {
                var fIfreset = $("[name='fIfreset']").val();
                var fResettype = $("[name='fResettype']").val();
                data.fIfreset && (fIfreset = data.fIfreset);
                data.fResettype && (fResettype = data.fResettype);
                if (fIfreset != "是") {
                    common.setComponentRequired(["fSkillcerfileList", "fManagecerfileList"], false,
                        'fileRequired');
                    common.setComponentRequired(["fSkillresettime", "fManageresettime"], false);
                    return;
                }
                if (fResettype == "技术归零") {
                    common.setComponentRequired(["fSkillcerfileList"], true, "fileRequired");
                    common.setComponentRequired(["fSkillresettime"], true);
                    common.setComponentRequired(["fManagecerfileList"], false, 'fileRequired');
                    common.setComponentRequired(["fManageresettime"], false);
                } else if (fResettype == "管理归零") {
                    common.setComponentRequired(["fManagecerfileList"], true, "fileRequired");
                    common.setComponentRequired(["fManageresettime"], true);
                    common.setComponentRequired(["fSkillcerfileList"], false, 'fileRequired');
                    common.setComponentRequired(["fSkillresettime"], false);
                } else if (fResettype == "双归零") {
                    common.setComponentRequired(["fSkillcerfileList", "fManagecerfileList"], true,
                        "fileRequired");
                    common.setComponentRequired(["fSkillresettime", "fManageresettime"], true);
                } else {
                    common.setComponentRequired(["fSkillcerfileList", "fManagecerfileList"], false,
                        'fileRequired');
                    common.setComponentRequired(["fSkillresettime", "fManageresettime"], false);
                }
                computeResetDay(data);
            }
        }
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        // 型号代号
        var xhdh = eval('${wQbdXhdhs}'); //型号代号
        var initXHDH = function (optionObj, item) {
            optionObj.text = item.fModelcode;
            optionObj.value = item.fModelcode;
            optionObj.setAttribute("xhmc", item.fModelname);
        };
        common.initDicData("fModelsymbol", xhdh, "", initXHDH);
        publicMethods.bottomFixd()
        form.on('select', function (data) {
            publicMethods.bottomFixd()
        });
        form.render();
        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload", {
            acceptMime: 'application/pdf, ' +
                'application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            exts: "doc|docx|pdf",
            secSelect: secSelect,
            isSub: false,
            isMultiFile: true,
            upLoadNumber: 1
        });


        $("#run").click(function () {
            var flag=form.VerifyForm("wQbdFalProblemresetDataForm");
            if(flag==false){
                return false;
            }
            runFlag=true;
            $("#urlFormSave").click();
        })
        function run(id) {
            var id = id;
            var fProblemname = $("input[name='fProblemname']").val();
            var fDetecttime = $("input[name='fDetecttime']").val();
            var fModelsymbol = $("select[name='fModelsymbol']").val();
            var fModelname = $("input[name='fModelname']").val();
            var fModelbatchno = $("input[name='fModelbatchno']").val();
            var fModeltype = $("select[name='fModeltype']").val();
            var fWorkphase1 = $("select[name='fWorkphase1']").val();
            var fProductname = $("input[name='fProductname']").val();
            var fModeldevelopphase = $("select[name='fModeldevelopphase']").val();
            var fProductbatchno = $("input[name='fProductbatchno']").val();
            var fProduceclass = $("input[name='fProduceclass']").val();
            var fBreakphase = $("select[name='fBreakphase']").val();
            var fProductlevel = $("input[name='fProductlevel']").val();
            var fProductdesigndept = $("input[name='fProductdesigndept']").val();
            var fProductproducedept = $("input[name='fProductproducedept']").val();
            var fDetectplace = $("input[name='fDetectplace']").val();
            var fSubsystemname = $("input[name='fSubsystemname']").val();
            var fIffirstfly = $("select[name='fIffirstfly']").val();
            var fIfshooting = $("select[name='fIfshooting']").val();
            var fIfbatch = $("input[name='fIfbatch']").val();
            var fIfthree = $("input[name='fIfthree']").val();
            var fProblemrank = $("input[name='fProblemrank']").val();
            var fSofthard = $("input[name='fSofthard']").val();
            var fProblemlever = $("select[name='fProblemlever']").val();
            var fResetday = $("input[name='fResetday']").val();
            var fFailuredescription = $("textarea[name='fFailuredescription']").val();
            var fDeepreason = $("input[name='fDeepreason']").val();
            var fCausation = $("input[name='fCausation']").val();
            var fFourrefer = $("input[name='fFourrefer']").val();
            var fCausationclass1 = $("input[name='fCausationclass1']").val();
            var fCausationclass2 = $("input[name='fCausationclass2']").val();
            var fCausationclass3 = $("input[name='fCausationclass3']").val();
            var fDutydept = $("input[name='fDutydept']").val();
            var fDutydeptnature = $("input[name='fDutydeptnature']").val();
            var fIfreset = $("input[name='fIfreset']").val();
            var fResettype = $("input[name='fResettype']").val();
            var fResettime = $("input[name='fResettime']").val();
            var fSolveresult = $("input[name='fSolveresult']").val();
            var fMeasureclass = $("input[name='fMeasureclass']").val();
            var fCorrectmeasure = $("input[name='fCorrectmeasure']").val();
            var fOutdeptname = $("input[name='fOutdeptname']").val();
            var fRanage = $("input[name='fRanage']").val();
            var fIndusty = $("input[name='fIndusty']").val();
            var fOutnature = $("input[name='fOutnature']").val();
            var fSoftrank = $("input[name='fSoftrank']").val();
            var fIschange = $("input[name='fIschange']").val();
            var fCurversion = $("input[name='fCurversion']").val();
            var fShowversion = $("input[name='fShowversion']").val();
            var fUpdateperson = $("input[name='fUpdateperson']").val();
            var fUpdatepersondept = $("input[name='fUpdatepersondept']").val();
            var fUpdatedate = $("input[name='fUpdatedate']").val();
            var fOriginalid = $("input[name='fOriginalid']").val();
            var fPreviousid = $("input[name='fPreviousid']").val();
            var belongdeptname = $("input[name='belongdeptname']").val();
            var tenantId = $("input[name='tenantId']").val();
            var fCreateby = $("input[name='fCreateby']").val();
            var fCreatetime = $("input[name='fCreatetime']").val();
            var fUpdateby = $("input[name='fUpdateby']").val();
            var fUpdatetime = $("input[name='fUpdatetime']").val();
            var fNum = $("input[name='fNum']").val();
            var fStatus = $("input[name='fStatus']").val();
            var fSuperviseid = $("input[name='fSuperviseid']").val();
            var fManagefactoranalysis = $("input[name='fManagefactoranalysis']").val();
            var fSkillresettime = $("input[name='fSkillresettime']").val();
            var fManageresettime = $("input[name='fManageresettime']").val();
            var fIfmating = $("input[name='fIfmating']").val();
            var fSkillcerfile = $("input[name='fSkillcerfile']").val();
            var fManagecerfile = $("input[name='fManagecerfile']").val();
            var fIfduty = $("input[name='fIfduty']").val();
            var fDutyinvestigationtyp = $("input[name='fDutyinvestigationtyp']").val();
            var fIdentification = $("input[name='fIdentification']").val();
            var fConfirmdutyinvest = $("input[name='fConfirmdutyinvest']").val();
            var fAllcount = $("input[name='fAllcount']").val();
            var fState = $("input[name='fState']").val();
            var reportStatus = $("input[name='reportStatus']").val();
            var fSupervise = $("input[name='fSupervise']").val();
            var fRewardpunid = $("input[name='fRewardpunid']").val();
            var fZhzlclyj = $("input[name='fZhzlclyj']").val();
            var fKybmldyj = $("input[name='fKybmldyj']").val();
            var qualityleader = $("input[name='qualityleader']").val();
            var fReportStatusTemp = $("input[name='fReportStatusTemp']").val();
            var fillman = $("input[name='fillman']").val();
            var fillmanaccount = $("input[name='fillmanaccount']").val();
            var filldept = $("input[name='filldept']").val();
            var filldeptid = $("input[name='filldeptid']").val();
            var secret = $("select[name='secret']").val();
            var reportReason = $("input[name='reportReason']").val();
            var returnmsg = $("input[name='returnmsg']").val();
            var filldepthospital = $("input[name='filldepthospital']").val();
            var filldepthospitalid = $("input[name='filldepthospitalid']").val();
            var reportDate = $("input[name='reportDate']").val();
            var filldate = $("input[name='filldate']").val();
            var punishRenson = $("input[name='punishRenson']").val();
            var fDutydeptRoom = $("select[name='fDutydeptRoom']").val();
            var fProblemQuantity = $("input[name='fProblemQuantity']").val();
            var fSubsystemnameFill = $("input[name='fSubsystemnameFill']").val();
            var fDutydeptRoomName = $("input[name='fDutydeptRoomName']").val();
            var flowStatus = $("input[name='flowStatus']").val();
            var nowData = {"id": id,"fProblemname": fProblemname,"fDetecttime": fDetecttime,"fModelsymbol": fModelsymbol,"fModelname": fModelname,"fModelbatchno": fModelbatchno,"fModeltype": fModeltype,"fWorkphase1": fWorkphase1,"fProductname": fProductname,"fModeldevelopphase": fModeldevelopphase,"fProductbatchno": fProductbatchno,"fProduceclass": fProduceclass,"fBreakphase": fBreakphase,"fProductlevel": fProductlevel,"fProductdesigndept": fProductdesigndept,"fProductproducedept": fProductproducedept,"fDetectplace": fDetectplace,"fSubsystemname": fSubsystemname,"fIffirstfly": fIffirstfly,"fIfshooting": fIfshooting,"fIfbatch": fIfbatch,"fIfthree": fIfthree,"fProblemrank": fProblemrank,"fSofthard": fSofthard,"fProblemlever": fProblemlever,"fResetday": fResetday,"fFailuredescription": fFailuredescription,"fDeepreason": fDeepreason,"fCausation": fCausation,"fFourrefer": fFourrefer,"fCausationclass1": fCausationclass1,"fCausationclass2": fCausationclass2,"fCausationclass3": fCausationclass3,"fDutydept": fDutydept,"fDutydeptnature": fDutydeptnature,"fIfreset": fIfreset,"fResettype": fResettype,"fResettime": fResettime,"fSolveresult": fSolveresult,"fMeasureclass": fMeasureclass,"fCorrectmeasure": fCorrectmeasure,"fOutdeptname": fOutdeptname,"fRanage": fRanage,"fIndusty": fIndusty,"fOutnature": fOutnature,"fSoftrank": fSoftrank,"fIschange": fIschange,"fCurversion": fCurversion,"fShowversion": fShowversion,"fUpdateperson": fUpdateperson,"fUpdatepersondept": fUpdatepersondept,"fUpdatedate": fUpdatedate,"fOriginalid": fOriginalid,"fPreviousid": fPreviousid,"belongdeptname": belongdeptname,"tenantId": tenantId,"fCreateby": fCreateby,"fCreatetime": fCreatetime,"fUpdateby": fUpdateby,"fUpdatetime": fUpdatetime,"fNum": fNum,"fStatus": fStatus,"fSuperviseid": fSuperviseid,"fManagefactoranalysis": fManagefactoranalysis,"fSkillresettime": fSkillresettime,"fManageresettime": fManageresettime,"fIfmating": fIfmating,"fSkillcerfile": fSkillcerfile,"fManagecerfile": fManagecerfile,"fIfduty": fIfduty,"fDutyinvestigationtyp": fDutyinvestigationtyp,"fIdentification": fIdentification,"fConfirmdutyinvest": fConfirmdutyinvest,"fAllcount": fAllcount,"fState": fState,"reportStatus": reportStatus,"fSupervise": fSupervise,"fRewardpunid": fRewardpunid,"fZhzlclyj": fZhzlclyj,"fKybmldyj": fKybmldyj,"qualityleader": qualityleader,"fReportStatusTemp": fReportStatusTemp,"fillman": fillman,"fillmanaccount": fillmanaccount,"filldept": filldept,"filldeptid": filldeptid,"secret": secret,"reportReason": reportReason,"returnmsg": returnmsg,"filldepthospital": filldepthospital,"filldepthospitalid": filldepthospitalid,"reportDate": reportDate,"filldate": filldate,"punishRenson": punishRenson,"fDutydeptRoom": fDutydeptRoom,"fProblemQuantity": fProblemQuantity,"fSubsystemnameFill": fSubsystemnameFill,"fDutydeptRoomName": fDutydeptRoomName,"flowStatus": flowStatus};
            $.ajax({
                url:"${ctx}/qbdms/wQbdFalProblemreset/run",
                type: "post",
                dataType: 'json',
                contentType : 'application/json',
                data: JSON.stringify(nowData),
                success : function (data) {
                    if (common.filterRecord(data)) {
                        layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
                        });
                    } else {
                        layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
                        });
                    }
                    return false;
                },
                error : function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(publicMethods.confirmStyle("内容已保存，启动失败"),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
                    });
                }
            })
        }
    });
</script>
</body>
</html>